package com.example.service;

import com.example.dao.PaperDao;
import com.example.entity.Paper;
import com.example.entity.Params;
import com.example.entity.Type;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;

@Service
public class PaperService {
    @Resource
    private PaperDao paperDao;

    public PageInfo<Paper> findBySearch(Params params) {
        //分页查询
        PageHelper.startPage(params.getPageNum(),params.getPageSize());

        List<Paper> list = paperDao.findBySearch(params);
        return PageInfo.of(list);
    }

    public void add(Paper paper) {
        paperDao.insertSelective(paper);
    }
    public void update(Paper paper) {
        paperDao.updateByPrimaryKeySelective(paper);
    }

    public void delete(Integer id) {
        paperDao.deleteByPrimaryKey(id);
    }

    public List<Paper> findAll() {
        return paperDao.selectAll();
    }

    public Paper findAnswer(Integer paperId) {
        return paperDao.findAnswer(paperId);
    }

    public List<Paper> findAll2() {
        return paperDao.findAll2();
    }

    public Integer findTypeId(String typeName) {
        return paperDao.findTypeId(typeName);
    }

    public Integer findNumber(String name) {
        return paperDao.findNumber(name);
    }
}
